package co.com.services.sedejornada;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.SedeJornadasDTO;
import co.com.smart.session.DelegateContextEJB;


@Path("/SmartSedeJornadasServices")
public class SedeJornadasServices {
	@GET
	@Path("/getAllSedeJornadas")
	@Produces(MediaType.APPLICATION_JSON)
	public Response getSedeJornadas() throws NamingException{
		return Response.ok(DelegateContextEJB.getSedeJornadasBeanLocal().consultarAllSedeJornadas())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
	
	@POST
	@Path("/getSedeJornadasId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getSedeJornadasId(SedeJornadasDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getSedeJornadasBeanLocal().consultarSedeJornadasId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setSedeJornadas")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setSedeJornadas( SedeJornadasDTO json){ 
		return Response.ok(DelegateContextEJB.getSedeJornadasBeanLocal().insertarSedeJornadas(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editSedeJornadas")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditSedeJornadas(SedeJornadasDTO json){ 
		return Response.ok(DelegateContextEJB.getSedeJornadasBeanLocal().editSedeJornadas(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeSedeJornadas")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveSedeJornadas(SedeJornadasDTO json){ 
		return Response.ok(DelegateContextEJB.getSedeJornadasBeanLocal().removeSedeJornadas(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}
}
